package com.jxmcloud.business.cut.service.impl.database;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jxmcloud.business.cut.dto.client.GiveUpModelDto;
import com.jxmcloud.business.cut.dtoCommon.GiveUpConfig;
import com.jxmcloud.business.cut.mapper.database.IUserGiveUpAwardConfigDBMapper;
import com.jxmcloud.business.cut.mapper.database.IUserGiveUpAwardRecordDBMapper;
import com.jxmcloud.business.cut.model.database.DBUserGiveUpAwardConfig;
import com.jxmcloud.business.cut.model.database.DBUserGiveUpAwardRecord;
import com.jxmcloud.business.cut.service.database.IUserGiveUpAwardConfigDBService;
import com.jxmcloud.business.cut.service.database.IUserGiveUpAwardRecordDBService;
import com.jxmcloud.business.cut.util.SerialNumberUtil;
import com.jxmcloud.business.cut.vo.toDb.ToDbUserGiveUpAwardRecord;
import org.apache.commons.beanutils.BeanUtils;
import org.springframework.stereotype.Service;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class UserGiveUpAwardRecordDBServiceImpl extends ServiceImpl<IUserGiveUpAwardRecordDBMapper, DBUserGiveUpAwardRecord> implements IUserGiveUpAwardRecordDBService {

    @Override
    public boolean insertIntoData(ToDbUserGiveUpAwardRecord toDbUserGiveUpAwardRecord) {
        DBUserGiveUpAwardRecord dbUserGiveUpAwardRecord = new DBUserGiveUpAwardRecord();
        try {
            BeanUtils.copyProperties(dbUserGiveUpAwardRecord, toDbUserGiveUpAwardRecord);
            dbUserGiveUpAwardRecord.setOrderNo(SerialNumberUtil.autoOrderNo());
            dbUserGiveUpAwardRecord.setSendStatus(0);
            dbUserGiveUpAwardRecord.setCreateTime(new Date());
            return this.getBaseMapper().insert(dbUserGiveUpAwardRecord) > 0;
        } catch (IllegalAccessException | InvocationTargetException e) {
            throw new RuntimeException(e);
        }
    }
}
